Left Termination of the query pattern lessleaves_in_2(g, g) w.r.t. the given Prolog program could successfully be proven:



Prolog
  ↳ PrologToPiTRSProof

Clauses:

append(nil, Y, Y).
append(cons(U, V), Y, cons(U, Z)) :- append(V, Y, Z).
lessleaves(nil, cons(W, Z)).
lessleaves(cons(U, V), cons(W, Z)) :- ','(append(U, V, U1), ','(append(W, Z, W1), lessleaves(U1, W1))).

Queries:

lessleaves(g,g).

We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

lessleaves_in(cons(U, V), cons(W, Z)) → U2(U, V, W, Z, append_in(U, V, U1))
append_in(cons(U, V), Y, cons(U, Z)) → U1(U, V, Y, Z, append_in(V, Y, Z))
append_in(nil, Y, Y) → append_out(nil, Y, Y)
U1(U, V, Y, Z, append_out(V, Y, Z)) → append_out(cons(U, V), Y, cons(U, Z))
U2(U, V, W, Z, append_out(U, V, U1)) → U3(U, V, W, Z, U1, append_in(W, Z, W1))
U3(U, V, W, Z, U1, append_out(W, Z, W1)) → U4(U, V, W, Z, lessleaves_in(U1, W1))
lessleaves_in(nil, cons(W, Z)) → lessleaves_out(nil, cons(W, Z))
U4(U, V, W, Z, lessleaves_out(U1, W1)) → lessleaves_out(cons(U, V), cons(W, Z))

The argument filtering Pi contains the following mapping:
lessleaves_in(x1, x2)  =  lessleaves_in(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U2(x1, x2, x3, x4, x5)  =  U2(x3, x4, x5)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x5)
nil  =  nil
append_out(x1, x2, x3)  =  append_out(x3)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
lessleaves_out(x1, x2)  =  lessleaves_out

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

lessleaves_in(cons(U, V), cons(W, Z)) → U2(U, V, W, Z, append_in(U, V, U1))
append_in(cons(U, V), Y, cons(U, Z)) → U1(U, V, Y, Z, append_in(V, Y, Z))
append_in(nil, Y, Y) → append_out(nil, Y, Y)
U1(U, V, Y, Z, append_out(V, Y, Z)) → append_out(cons(U, V), Y, cons(U, Z))
U2(U, V, W, Z, append_out(U, V, U1)) → U3(U, V, W, Z, U1, append_in(W, Z, W1))
U3(U, V, W, Z, U1, append_out(W, Z, W1)) → U4(U, V, W, Z, lessleaves_in(U1, W1))
lessleaves_in(nil, cons(W, Z)) → lessleaves_out(nil, cons(W, Z))
U4(U, V, W, Z, lessleaves_out(U1, W1)) → lessleaves_out(cons(U, V), cons(W, Z))

The argument filtering Pi contains the following mapping:
lessleaves_in(x1, x2)  =  lessleaves_in(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U2(x1, x2, x3, x4, x5)  =  U2(x3, x4, x5)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x5)
nil  =  nil
append_out(x1, x2, x3)  =  append_out(x3)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
lessleaves_out(x1, x2)  =  lessleaves_out


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

LESSLEAVES_IN(cons(U, V), cons(W, Z)) → U21(U, V, W, Z, append_in(U, V, U1))
LESSLEAVES_IN(cons(U, V), cons(W, Z)) → APPEND_IN(U, V, U1)
APPEND_IN(cons(U, V), Y, cons(U, Z)) → U11(U, V, Y, Z, append_in(V, Y, Z))
APPEND_IN(cons(U, V), Y, cons(U, Z)) → APPEND_IN(V, Y, Z)
U21(U, V, W, Z, append_out(U, V, U1)) → U31(U, V, W, Z, U1, append_in(W, Z, W1))
U21(U, V, W, Z, append_out(U, V, U1)) → APPEND_IN(W, Z, W1)
U31(U, V, W, Z, U1, append_out(W, Z, W1)) → U41(U, V, W, Z, lessleaves_in(U1, W1))
U31(U, V, W, Z, U1, append_out(W, Z, W1)) → LESSLEAVES_IN(U1, W1)

The TRS R consists of the following rules:

lessleaves_in(cons(U, V), cons(W, Z)) → U2(U, V, W, Z, append_in(U, V, U1))
append_in(cons(U, V), Y, cons(U, Z)) → U1(U, V, Y, Z, append_in(V, Y, Z))
append_in(nil, Y, Y) → append_out(nil, Y, Y)
U1(U, V, Y, Z, append_out(V, Y, Z)) → append_out(cons(U, V), Y, cons(U, Z))
U2(U, V, W, Z, append_out(U, V, U1)) → U3(U, V, W, Z, U1, append_in(W, Z, W1))
U3(U, V, W, Z, U1, append_out(W, Z, W1)) → U4(U, V, W, Z, lessleaves_in(U1, W1))
lessleaves_in(nil, cons(W, Z)) → lessleaves_out(nil, cons(W, Z))
U4(U, V, W, Z, lessleaves_out(U1, W1)) → lessleaves_out(cons(U, V), cons(W, Z))

The argument filtering Pi contains the following mapping:
lessleaves_in(x1, x2)  =  lessleaves_in(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U2(x1, x2, x3, x4, x5)  =  U2(x3, x4, x5)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x5)
nil  =  nil
append_out(x1, x2, x3)  =  append_out(x3)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
lessleaves_out(x1, x2)  =  lessleaves_out
U41(x1, x2, x3, x4, x5)  =  U41(x5)
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)
LESSLEAVES_IN(x1, x2)  =  LESSLEAVES_IN(x1, x2)
U21(x1, x2, x3, x4, x5)  =  U21(x3, x4, x5)
U11(x1, x2, x3, x4, x5)  =  U11(x1, x5)
U31(x1, x2, x3, x4, x5, x6)  =  U31(x5, x6)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

Pi DP problem:
The TRS P consists of the following rules:

LESSLEAVES_IN(cons(U, V), cons(W, Z)) → U21(U, V, W, Z, append_in(U, V, U1))
LESSLEAVES_IN(cons(U, V), cons(W, Z)) → APPEND_IN(U, V, U1)
APPEND_IN(cons(U, V), Y, cons(U, Z)) → U11(U, V, Y, Z, append_in(V, Y, Z))
APPEND_IN(cons(U, V), Y, cons(U, Z)) → APPEND_IN(V, Y, Z)
U21(U, V, W, Z, append_out(U, V, U1)) → U31(U, V, W, Z, U1, append_in(W, Z, W1))
U21(U, V, W, Z, append_out(U, V, U1)) → APPEND_IN(W, Z, W1)
U31(U, V, W, Z, U1, append_out(W, Z, W1)) → U41(U, V, W, Z, lessleaves_in(U1, W1))
U31(U, V, W, Z, U1, append_out(W, Z, W1)) → LESSLEAVES_IN(U1, W1)

The TRS R consists of the following rules:

lessleaves_in(cons(U, V), cons(W, Z)) → U2(U, V, W, Z, append_in(U, V, U1))
append_in(cons(U, V), Y, cons(U, Z)) → U1(U, V, Y, Z, append_in(V, Y, Z))
append_in(nil, Y, Y) → append_out(nil, Y, Y)
U1(U, V, Y, Z, append_out(V, Y, Z)) → append_out(cons(U, V), Y, cons(U, Z))
U2(U, V, W, Z, append_out(U, V, U1)) → U3(U, V, W, Z, U1, append_in(W, Z, W1))
U3(U, V, W, Z, U1, append_out(W, Z, W1)) → U4(U, V, W, Z, lessleaves_in(U1, W1))
lessleaves_in(nil, cons(W, Z)) → lessleaves_out(nil, cons(W, Z))
U4(U, V, W, Z, lessleaves_out(U1, W1)) → lessleaves_out(cons(U, V), cons(W, Z))

The argument filtering Pi contains the following mapping:
lessleaves_in(x1, x2)  =  lessleaves_in(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U2(x1, x2, x3, x4, x5)  =  U2(x3, x4, x5)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x5)
nil  =  nil
append_out(x1, x2, x3)  =  append_out(x3)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
lessleaves_out(x1, x2)  =  lessleaves_out
U41(x1, x2, x3, x4, x5)  =  U41(x5)
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)
LESSLEAVES_IN(x1, x2)  =  LESSLEAVES_IN(x1, x2)
U21(x1, x2, x3, x4, x5)  =  U21(x3, x4, x5)
U11(x1, x2, x3, x4, x5)  =  U11(x1, x5)
U31(x1, x2, x3, x4, x5, x6)  =  U31(x5, x6)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 2 SCCs with 4 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
PiDP
                ↳ UsableRulesProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

APPEND_IN(cons(U, V), Y, cons(U, Z)) → APPEND_IN(V, Y, Z)

The TRS R consists of the following rules:

lessleaves_in(cons(U, V), cons(W, Z)) → U2(U, V, W, Z, append_in(U, V, U1))
append_in(cons(U, V), Y, cons(U, Z)) → U1(U, V, Y, Z, append_in(V, Y, Z))
append_in(nil, Y, Y) → append_out(nil, Y, Y)
U1(U, V, Y, Z, append_out(V, Y, Z)) → append_out(cons(U, V), Y, cons(U, Z))
U2(U, V, W, Z, append_out(U, V, U1)) → U3(U, V, W, Z, U1, append_in(W, Z, W1))
U3(U, V, W, Z, U1, append_out(W, Z, W1)) → U4(U, V, W, Z, lessleaves_in(U1, W1))
lessleaves_in(nil, cons(W, Z)) → lessleaves_out(nil, cons(W, Z))
U4(U, V, W, Z, lessleaves_out(U1, W1)) → lessleaves_out(cons(U, V), cons(W, Z))

The argument filtering Pi contains the following mapping:
lessleaves_in(x1, x2)  =  lessleaves_in(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U2(x1, x2, x3, x4, x5)  =  U2(x3, x4, x5)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x5)
nil  =  nil
append_out(x1, x2, x3)  =  append_out(x3)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
lessleaves_out(x1, x2)  =  lessleaves_out
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

APPEND_IN(cons(U, V), Y, cons(U, Z)) → APPEND_IN(V, Y, Z)

R is empty.
The argument filtering Pi contains the following mapping:
cons(x1, x2)  =  cons(x1, x2)
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP

Q DP problem:
The TRS P consists of the following rules:

APPEND_IN(cons(U, V), Y) → APPEND_IN(V, Y)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
PiDP
                ↳ UsableRulesProof

Pi DP problem:
The TRS P consists of the following rules:

U21(U, V, W, Z, append_out(U, V, U1)) → U31(U, V, W, Z, U1, append_in(W, Z, W1))
U31(U, V, W, Z, U1, append_out(W, Z, W1)) → LESSLEAVES_IN(U1, W1)
LESSLEAVES_IN(cons(U, V), cons(W, Z)) → U21(U, V, W, Z, append_in(U, V, U1))

The TRS R consists of the following rules:

lessleaves_in(cons(U, V), cons(W, Z)) → U2(U, V, W, Z, append_in(U, V, U1))
append_in(cons(U, V), Y, cons(U, Z)) → U1(U, V, Y, Z, append_in(V, Y, Z))
append_in(nil, Y, Y) → append_out(nil, Y, Y)
U1(U, V, Y, Z, append_out(V, Y, Z)) → append_out(cons(U, V), Y, cons(U, Z))
U2(U, V, W, Z, append_out(U, V, U1)) → U3(U, V, W, Z, U1, append_in(W, Z, W1))
U3(U, V, W, Z, U1, append_out(W, Z, W1)) → U4(U, V, W, Z, lessleaves_in(U1, W1))
lessleaves_in(nil, cons(W, Z)) → lessleaves_out(nil, cons(W, Z))
U4(U, V, W, Z, lessleaves_out(U1, W1)) → lessleaves_out(cons(U, V), cons(W, Z))

The argument filtering Pi contains the following mapping:
lessleaves_in(x1, x2)  =  lessleaves_in(x1, x2)
cons(x1, x2)  =  cons(x1, x2)
U2(x1, x2, x3, x4, x5)  =  U2(x3, x4, x5)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x5)
nil  =  nil
append_out(x1, x2, x3)  =  append_out(x3)
U3(x1, x2, x3, x4, x5, x6)  =  U3(x5, x6)
U4(x1, x2, x3, x4, x5)  =  U4(x5)
lessleaves_out(x1, x2)  =  lessleaves_out
LESSLEAVES_IN(x1, x2)  =  LESSLEAVES_IN(x1, x2)
U21(x1, x2, x3, x4, x5)  =  U21(x3, x4, x5)
U31(x1, x2, x3, x4, x5, x6)  =  U31(x5, x6)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof

Pi DP problem:
The TRS P consists of the following rules:

U21(U, V, W, Z, append_out(U, V, U1)) → U31(U, V, W, Z, U1, append_in(W, Z, W1))
U31(U, V, W, Z, U1, append_out(W, Z, W1)) → LESSLEAVES_IN(U1, W1)
LESSLEAVES_IN(cons(U, V), cons(W, Z)) → U21(U, V, W, Z, append_in(U, V, U1))

The TRS R consists of the following rules:

append_in(cons(U, V), Y, cons(U, Z)) → U1(U, V, Y, Z, append_in(V, Y, Z))
append_in(nil, Y, Y) → append_out(nil, Y, Y)
U1(U, V, Y, Z, append_out(V, Y, Z)) → append_out(cons(U, V), Y, cons(U, Z))

The argument filtering Pi contains the following mapping:
cons(x1, x2)  =  cons(x1, x2)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x1, x5)
nil  =  nil
append_out(x1, x2, x3)  =  append_out(x3)
LESSLEAVES_IN(x1, x2)  =  LESSLEAVES_IN(x1, x2)
U21(x1, x2, x3, x4, x5)  =  U21(x3, x4, x5)
U31(x1, x2, x3, x4, x5, x6)  =  U31(x5, x6)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ UsableRulesReductionPairsProof

Q DP problem:
The TRS P consists of the following rules:

U21(W, Z, append_out(U1)) → U31(U1, append_in(W, Z))
LESSLEAVES_IN(cons(U, V), cons(W, Z)) → U21(W, Z, append_in(U, V))
U31(U1, append_out(W1)) → LESSLEAVES_IN(U1, W1)

The TRS R consists of the following rules:

append_in(cons(U, V), Y) → U1(U, append_in(V, Y))
append_in(nil, Y) → append_out(Y)
U1(U, append_out(Z)) → append_out(cons(U, Z))

The set Q consists of the following terms:

append_in(x0, x1)
U1(x0, x1)

We have to consider all (P,Q,R)-chains.
By using the usable rules with reduction pair processor [15] with a polynomial ordering [25], all dependency pairs and the corresponding usable rules [17] can be oriented non-strictly. All non-usable rules are removed, and those dependency pairs and usable rules that have been oriented strictly or contain non-usable symbols in their left-hand side are removed as well.

The following dependency pairs can be deleted:

U21(W, Z, append_out(U1)) → U31(U1, append_in(W, Z))
U31(U1, append_out(W1)) → LESSLEAVES_IN(U1, W1)
The following rules are removed from R:

append_in(nil, Y) → append_out(Y)
Used ordering: POLO with Polynomial interpretation [25]:

POL(LESSLEAVES_IN(x1, x2)) = 2·x1 + x2   
POL(U1(x1, x2)) = 2·x1 + x2   
POL(U21(x1, x2, x3)) = x1 + x2 + 2·x3   
POL(U31(x1, x2)) = 1 + 2·x1 + x2   
POL(append_in(x1, x2)) = x1 + x2   
POL(append_out(x1)) = 1 + x1   
POL(cons(x1, x2)) = 2·x1 + x2   
POL(nil) = 2   



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
                      ↳ QDP
                        ↳ UsableRulesReductionPairsProof
QDP
                            ↳ DependencyGraphProof

Q DP problem:
The TRS P consists of the following rules:

LESSLEAVES_IN(cons(U, V), cons(W, Z)) → U21(W, Z, append_in(U, V))

The TRS R consists of the following rules:

append_in(cons(U, V), Y) → U1(U, append_in(V, Y))
U1(U, append_out(Z)) → append_out(cons(U, Z))

The set Q consists of the following terms:

append_in(x0, x1)
U1(x0, x1)

We have to consider all (P,Q,R)-chains.
The approximation of the Dependency Graph [15,17,22] contains 0 SCCs with 1 less node.